package com.scau.yangsuiyu.estore.controller.buyer.manageBasicInfo;

import com.scau.yangsuiyu.estore.dababases.entity.Buyer;
import de.felixroske.jfxsupport.FXMLController;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.layout.AnchorPane;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @author suiyu_yang
 * @description 买家个人信息管理界面的Controller
 * @date 2019-06-08 12:52
 * @email suiyu_yang@163.com
 */
@FXMLController
public class ManageBuyerInfo extends AnchorPane implements Initializable {
    private Buyer buyer;


    @FXML
    private AnchorPane buyerDetailPane;


    public ManageBuyerInfo() {
        this.buyer = new Buyer();
        loadFXML();
    }

    public ManageBuyerInfo(Buyer buyer) {
        this.buyer = buyer;
        loadFXML();
    }

    private void loadFXML() {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/view/buyer/manageBasicInfo/ManageBuyerInfo.fxml"));
        fxmlLoader.setRoot(this);
        fxmlLoader.setController(this);
        try {
            fxmlLoader.load();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        InfoMessageBuyer infoMessageBuyer = new InfoMessageBuyer(buyer);
        buyerDetailPane.getChildren().add(infoMessageBuyer);
    }

    @FXML
    private void gotoSecurityManage() {
        buyerDetailPane.getChildren().clear();
        InfoSecurityBuyer infoSecurity = new InfoSecurityBuyer(buyer);
        buyerDetailPane.getChildren().add(infoSecurity);

    }

    @FXML
    private void gotoBuyerMessage() {
        buyerDetailPane.getChildren().clear();
        InfoMessageBuyer infoMessageBuyer = new InfoMessageBuyer(buyer);
        buyerDetailPane.getChildren().add(infoMessageBuyer);
    }

    @FXML
    private void gotoDeliveryAddressManage() {
        buyerDetailPane.getChildren().clear();
        InfoDeliveryAddressPane infoDeliveryAddressPane = new InfoDeliveryAddressPane(buyer);
        buyerDetailPane.getChildren().add(infoDeliveryAddressPane);
    }
}
